export const stringToObject = (data: string) => {
  const obj: any = {}
  // data = data.slice(1, data.length - 1)
  data.split('&').forEach((item) => {
    const arr = item.split('=')
    obj[arr[0]] = arr[1].replace(/%/g, ' ')
  })
  return obj
}
export const downloadType: any = {
  text: 'text/plain',
  txt: 'text/plain',
  jpg: 'image/jpeg',
  png: 'image/png',
}

export const getFileType = (val: string) => {
  const arr = ['jpg', 'jpeg', 'png', 'webp']
  if (arr.findIndex((v) => v === val) > -1) {
    return 'picture'
  } else {
    return 'file'
  }
}
